<template>
  <div class="app-container">
    <NewMap/>
  </div>
</template>

<script>
    import { listUser, getUser, delUser, addUser, updateUser } from "@/api/wechat/user";
    import { getRecordByUserId, delRecord, updateRecord, addRecord, getRecord, getRecordByUserIdAndState } from "@/api/wechat/record";
    import {checkPermi} from "../../../utils/permission";
    import NewMap from '../NewMap/index'
    export default {
        name: "approval",
        dicts: ['wx_user_state','sys_user_sex'],
        components: { NewMap },
        data() {
            return {
                pageSizes:[12,24,36],
                // 遮罩层
                loading: true,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 字典表格数据
                userList: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                // 日期范围
                dateRange: [],
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 12,
                    username: undefined,
                    password: undefined,
                    phone: undefined,
                    state: 0
                },
                recordParams: {
                    userId: undefined,
                    state: 0
                },
                // 密码显示隐藏
                show: true,
                //当前行
                currentIndex: null,
                // 表单参数
                form: {},
                // 表单校验
                rules: {
                    username: [
                        { required: true, message: "患者姓名不能为空", trigger: "blur" }
                    ],
                    password: [
                        { required: true, message: "密码不能为空", trigger: "blur" }
                    ]
                },
                display: 'list',
                disabled: true
            };
        },
        created() {
            this.getList();
        },
        activated() {
            this.getList();
        },
        methods: {
            /** 查询患者列表 */
            getList() {
                this.loading = true;
                listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
                        this.userList = response.rows;
                        this.total = response.total;
                        this.loading = false;
                    }
                );
            },
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.queryParams.state = 0;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.dateRange = [];
                this.resetForm("queryForm");
                this.handleQuery();
            },
            /** 取消按钮 */
            cancel() {
                this.open = false;
                this.reset();
            },
            /** 表单重置 **/
            reset() {
                this.form = {
                    username: undefined,
                    gender: undefined,
                    age: undefined,
                    address: undefined,
                    phone: undefined,
                    identityCard: undefined,
                    remark: undefined
                };
                this.resetForm("form");
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const userId = row.userId || this.ids
                this.recordParams.userId = userId
                getUser(userId).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "修改患者信息";
                    this.disabled = false;
                });
            },
            /** 查看按钮操作 */
            handleView(row) {
                this.reset();
                const userId = row.userId || this.ids
                this.recordParams.userId = userId
                getUser(userId).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "查看患者信息";
                    this.disabled = true;
                });
            },
            /** 提交按钮 */
            submitForm: function() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.form.userId != undefined) {
                            updateUser(this.form).then(response => {
                                this.$modal.msgSuccess("修改成功");
                                this.open = false;
                                this.getList();
                            });
                        } else {
                            addUser(this.form).then(response => {
                                this.$modal.msgSuccess("新增成功");
                                this.open = false;
                                this.getList();
                            });
                        }
                    }
                });
            },
            /** 多选框选中数据 */
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.userId)
                this.single = selection.length!=1
                this.multiple = !selection.length
            },

            // /** 删除按钮操作 */
            // handleDelete(row) {
            //     const userIds = row.userId || this.ids;
            //     this.$modal.confirm('是否确认删除患者编号为"' + userIds + '"的数据项？').then(function() {
            //         return delUser(userIds);
            //     }).then(() => {
            //         this.getList();
            //         this.$modal.msgSuccess("删除成功");
            //     }).catch(() => {});
            // },
            /** 显示隐藏 */
            setShow(index) {
                if (this.show) {
                    this.currentIndex = approval
                    this.show = false
                } else {
                    this.currentIndex = null
                    this.show = true
                }
            },

            /** 复制 */
            copy(shareiot) {
                var input = document.createElement('input')
                input.value = shareiot
                document.body.appendChild(input)
                input.select()
                document.execCommand('Copy')
                document.body.removeChild(input)
                this.$modal.msgSuccess("复制成功");
            },

            /** 操作 */
            operation(row){
                const userId = row.userId;
                this.$router.push("/wxchat/record/auditInfo/" + userId);
            },
            changeDisplay(value){
                this.display = value
                console.log(value)
            }
        }
    };
</script>
<style lang="scss" scoped>
    .form-box{
      /*height: 100;*/
      width: 100%;
      overflow-y: scroll;
    }

     .file-box{
      padding: 40px;
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: left;

    }
    .file-box .img{
      width: 220px;
      height: 350px;
      border-radius: 5px;
      object-fit: contain;
      padding: 20px;
    }
    .el-col{
      margin-top: 10px;
    }

  .content-main{
    display: flex;
    flex-direction: row;
    .user-avatar{
      width: 100px;
      height: 100px;
      border-radius: 15px;
      margin: 10px;
    }
    .content-text{
      display: flex;
      flex-direction: column;
      padding: 10px;
      .user-name{
        font-size: 24px;
        font-weight: bold;
      }
      .param-box{
        display: flex;
        flex-direction: row;
        margin-top: 15px;
        .param{
          margin-right: 30px;
          .label{
            margin-bottom: 10px;
            color: #5a5e66;
          }
          &:last-child {
            margin-right: 0;
          }
        }
      }
    }
  }
  .button-group{
    width: 100%;
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    button{
      width: 32%;
      height: 35px;
      font-size: 17px;
      background-color: #f6f6f6;
      border: 1px solid #e6e6e6;
      color: #409EFF;
      i{
        margin-right: 10px;
      }
    }
    button:disabled{
      pointer-events: none;
      cursor: not-allowed;
      color: #f6f6f6;
      background-color: #e6e6e6;
    }

    button:hover{
      color: #f6f6f6;
      background-color: #409EFF;

    }
  }


</style>
